/* GUI CONVERTED from reoptrc.p (converter v1.75) Sat Aug 12 23:07:47 2000 */
/* reoptrc.p - CALCULATE VARIANCES FOR LABOR & DOWNTIME TRANSACTIONS    */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/*F0PN*/ /*V8:ConvertMode=Maintenance                                   */
/*N014*/ /*V8:RunMode=Character,Windows                                 */
/* REVISION: 4.0      LAST MODIFIED: 03/25/88   BY: WUG *A187**/
/* REVISION: 4.0      LAST MODIFIED: 05/04/88   BY: flm *A222**/
/* REVISION: 4.0      LAST MODIFIED: 08/26/88   BY: flm *A411**/
/* REVISION: 4.0      LAST MODIFIED: 09/09/88   BY: flm *A431**/
/* REVISION: 4.0      LAST MODIFIED: 01/05/89   BY: flm *A571**/
/* REVISION: 5.0      LAST MODIFIED: 01/16/89   BY: flm *B015**/
/* REVISION: 4.0      LAST MODIFIED: 02/01/89   BY: flm *A633**/
/* REVISION: 4.0      LAST MODIFIED: 02/02/89   BY: flm *A580**/
/* REVISION: 5.0      LAST MODIFIED: 02/28/89   BY: flm *B055**/
/* REVISION: 5.0      LAST MODIFIED: 04/24/89   BY: flm *B103**/
/* REVISION: 6.0      LAST MODIFIED: 03/14/91   BY: WUG *D472**/
/* REVISION: 6.0      LAST MODIFIED: 04/09/91   BY: WUG *D503**/
/* REVISION: 6.0      LAST MODIFIED: 08/09/91   BY: pma *D806**/
/* REVISION: 7.0      LAST MODIFIED: 10/08/91   BY: pma *F003**/
/* REVISION: 7.2      LAST MODIFIED: 12/08/92   BY: emb *G767**/
/* REVISION: 7.2      LAST MODIFIED: 02/17/94   BY: ais *FM22**/
/* REVISION: 8.5      LAST MODIFIED: 11/15/95   BY: sxb *J053**/
/* REVISION: 8.5      LAST MODIFIED: 11/06/97   BY: *H1GH*  Manmohan Pardesi  */
/* REVISION: 8.6      LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 10/01/99   BY: *N014* Murali Ayyagari    */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb                */

         {mfdeclre.i}

         define shared variable wr_recno as recid.
         define shared variable wc_recno as recid.
         define shared variable pay_rate like emp_pay_rate.
         define shared variable op_recno as recid.

         define new shared variable sf_gl_amt like tr_gl_amt.
         define new shared variable sf_cr_acct like dpt_lbr_acct.
         define new shared variable sf_dr_acct like dpt_lbr_acct.
/*N014*/ define new shared variable sf_cr_sub like dpt_lbr_sub.
/*N014*/ define new shared variable sf_dr_sub like dpt_lbr_sub.
         define new shared variable sf_cr_cc like dpt_lbr_cc.
         define new shared variable sf_dr_cc like dpt_lbr_cc.
         define new shared variable ref like glt_ref.

/*F003   define
/*D503*/    shared
            variable prev_found like mfc_logical. */
         define variable sf_lbr_acct like dpt_lbr_acct.
         define variable sf_bdn_acct like dpt_bdn_acct.
         define variable sf_wip_acct like dpt_lbr_acct.
/*N014*  define variable sf_cop_acct like dpt_lbr_acct. */
/*N014*/ define variable sf_cop_acct like dpt_cop_acct.
/*N014*/ define variable sf_lbr_sub  like dpt_lbr_sub.
/*N014*/ define variable sf_bdn_sub  like dpt_bdn_sub.
/*N014*/ define variable sf_wip_sub  like dpt_lbr_sub.
/*N014*/ define variable sf_cop_sub  like dpt_cop_sub.
         define variable sf_lbr_cc like dpt_lbr_cc.
/*N014*  define variable sf_bdn_cc like dpt_lbr_cc. */
/*N014*/ define variable sf_bdn_cc like dpt_bdn_cc.
         define variable sf_wip_cc like dpt_lbr_cc.
         define variable sf_cop_cc like dpt_cop_cc.
/*D472*/ define new shared variable sf_entity like en_entity.

/*F003 DELETED FOLLOWING SECTION**
 * /*D806*/ define variable lbr_use_acct like dpt_lvar_acc.
 * /*D806*/ define variable lbr_rate_acct like dpt_oth_acct.
 * /*D806*/ define variable bdn_use_acct like dpt_reg_acct.
 * /*D806*/ define variable bdn_rate_acct like dpt_ot_acct.
 * /*D806*/ define variable lbr_use_cc like dpt_lvar_cc.
 * /*D806*/ define variable lbr_rate_cc like dpt_oth_cc.
 * /*D806*/ define variable bdn_use_cc like dpt_reg_cc.
 * /*D806*/ define variable bdn_rate_cc like dpt_ot_cc.
 * /*D806*/ define variable stdrun like op_act_run.
 * /*D806*/ define variable stdbdn like wc_lbr_rate.
 * /*D806*/ define variable actbdn like wc_lbr_rate.
**F003 END DELETED SECTION*/

/*F003*/ define new shared variable opgltype like opgl_type.

         find wr_route where recid(wr_route) = wr_recno.

/*D503********
      *  prev_found = no.
      *  find first op_hist where op_wo_lot = wr_lot
      *  and op_wo_op = wr_op and op_type = "LABOR" no-lock no-error.
      *  if available op_hist then prev_found = yes.
*********/

         find wc_mstr where recid(wc_mstr) = wc_recno no-lock.
         find op_hist where recid(op_hist) = op_recno.

         find first gl_ctrl no-lock.

/*F003*********************************************************/
/*   REPLACED PREVIOUSLY EXISTING LOGIC IN ITS ENTIRETY       */
/*                     WITH SFOPTRC1.P                        */
/*F003*********************************************************/

/*F003*/ if op_type = "LABOR" then do:
/*F003*/    {gprun.i ""sfoptrc1.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

/*F003*/ end.


/*F003************************************************************************/
/*    THE FOLLOWING SECTION OF CODE IS NEEDED BECAUSE DOWNTIME TRANSACTIONS  */
/*    HAVE ZERO QTY COMPLETE; THEREFORE THE LABOR AND BURDEN CALCULATIONS:   */
/*        sf_gl_amt = (op_qty_comp + op_qty_rjct) * wr_run * wc_lbr_rate.    */
/*    WILL ALWAYS = 0.                                                       */
/*F003************************************************************************/

         if op_type = "DOWNTIME" then do:

/*G767*/ /* ADDED SECTION*/
            sf_entity = glentity.
            find wo_mstr no-lock where wo_lot = op_wo_lot
            and wo_nbr = op_wo_nbr no-error.
            if available wo_mstr then do:
               find si_mstr where si_site = wo_site no-lock.
               sf_entity = si_entity.
            end.
/*G767*/ /* END OF ADDED SECTION*/

/*FM22*/ /*** DELETE THE FOLLOWING CODE ******************************
/*F003*/  * find dpt_mstr where dpt_dept = wc_dept no-lock no-error.
/*F003*/  * if available dpt_mstr and dpt_cop_acct <> "" then
/*F003*/  *    assign sf_cop_acct = dpt_cop_acct sf_cop_cc = dpt_cop_cc.
/*F003*/  * else
/*F003*/  *    assign sf_cop_acct = gl_cop_acct sf_cop_cc = gl_cop_cc.
/*FM22*/  ** DELETE THE ABOVE CODE ***********************************/

/*F003*/    find dpt_mstr where dpt_dept = op_dept no-lock no-error.
/*F003*/    if available dpt_mstr then do:
/*FM22*/       if dpt_cop_acct <> "" then
/*FM22*/          assign sf_cop_acct = dpt_cop_acct
/*N014*/                 sf_cop_sub  = dpt_cop_sub
/*FM22*/                 sf_cop_cc = dpt_cop_cc.
/*FM22*/       else
/*FM22*/          assign sf_cop_acct = gl_cop_acct
/*N014*/                 sf_cop_sub  = gl_cop_sub
/*FM22*/                 sf_cop_cc = gl_cop_cc.
/*F003*/       if dpt_lbr_acct <> "" then
/*F003*/          assign sf_lbr_acct = dpt_lbr_acct
/*N014*/                 sf_lbr_sub  = dpt_lbr_sub
/*F003*/                 sf_lbr_cc = dpt_lbr_cc.
/*F003*/       else
/*F003*/          assign sf_lbr_acct = gl_lbr_acct
/*N014*/                 sf_lbr_sub  = gl_lbr_sub
/*F003*/                 sf_lbr_cc = gl_lbr_cc.
/*F003*/       if dpt_bdn_acct <> "" then
/*F003*/          assign sf_bdn_acct = dpt_bdn_acct
/*N014*/                 sf_bdn_sub  = dpt_bdn_sub
/*F003*/                 sf_bdn_cc = dpt_bdn_cc.
/*F003*/       else
/*F003*/          assign sf_bdn_acct = gl_bdn_acct
/*N014*/                 sf_bdn_sub = gl_bdn_sub
/*F003*/                 sf_bdn_cc = gl_bdn_cc.
/*F003*/    end.
/*F003*/    else do:
/*FM22*/       assign sf_cop_acct = gl_cop_acct
/*N014*/              sf_cop_sub = gl_cop_sub
/*FM22*/              sf_cop_cc = gl_cop_cc
/*F003*/       sf_lbr_acct = gl_lbr_acct
/*N014*/       sf_lbr_sub = gl_lbr_sub
/*F003*/       sf_lbr_cc = gl_lbr_cc
/*F003*/       sf_bdn_acct = gl_bdn_acct
/*N014*/       sf_bdn_sub = gl_bdn_sub
/*F003*/       sf_bdn_cc = gl_bdn_cc.
/*F003*/    end.

/*H1GH** COMMENTED OUT SO THAT MACHINE BURDEN IS NOT INCLUDED IN THE
 *       CALCULATION OF ACTUAL BURDEN COST AT OPERATION.
 *          sf_gl_amt = (wc_bdn_rate + wc_mch_bdn +
 *                       (wc_lbr_rate * wc_bdn_pc * .01)) * op_act_run.
 *H1GH** */

/*H1GH*/ {gprun.i ""rwbdncal.p""
          "(input 'LABOR',
            input no,
            input (wc_bdn_pc * 0.01),
            input wc_bdn_rate,
            input wc_lbr_rate,
            input 0,
            input 0,
            input 0,
            input op_act_run,
            input 0,
            input 0,
            input 1,
            input-output sf_gl_amt)"}
/*GUI*/ if global-beam-me-up then undo, leave.


            /* ROUND AMOUNT ACCORDING TO BASE ROUNDING METHOD */
/*J053*/    {gprun.i ""gpcurrnd.p"" "(input-output sf_gl_amt,
                                      input gl_rnd_mthd)"}
/*GUI*/ if global-beam-me-up then undo, leave.

/*N014*/    assign
/*F003*/    opgltype = "BDN-2000"
            sf_dr_acct = sf_cop_acct
/*N014*/    sf_dr_sub = sf_cop_sub
            sf_dr_cc = sf_cop_cc
            sf_cr_acct = sf_bdn_acct
/*N014*/    sf_cr_sub = sf_bdn_sub
            sf_cr_cc = sf_bdn_cc.

            {gprun.i ""sfopgl.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


/*F003*/    op_bdn_cost = op_bdn_cost + sf_gl_amt.
/*F003*/    op_bdn_std = op_bdn_std + sf_gl_amt.

/*D503*/    if op_wkctr = ""
/*D503*/    then sf_gl_amt = pay_rate * op_act_run.
/*D503*/    else sf_gl_amt = wc_lbr_rate * op_act_run.

            /* ROUND AMOUNT ACCORDING TO BASE ROUNDING METHOD */
/*J053*/    {gprun.i ""gpcurrnd.p"" "(input-output sf_gl_amt,
                                      input gl_rnd_mthd)"}
/*GUI*/ if global-beam-me-up then undo, leave.

/*N014*/    assign
/*F003*/    opgltype = "LBR-2000"
            sf_cr_acct = sf_lbr_acct
/*N014*/    sf_cr_sub = sf_lbr_sub
            sf_cr_cc = sf_lbr_cc.

            {gprun.i ""sfopgl.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


/*F003*/    op_lbr_cost = op_lbr_cost + sf_gl_amt.
/*D806*/    op_lbr_std = op_lbr_std + sf_gl_amt.

         end.
